<template>
  <div class="mod-api__tmcompany">
    <el-form :inline="true" :model="state.dataForm" @keyup.enter="state.getDataList()">
      <el-form-item>
        <el-input v-model.trim="state.dataForm.companyName" placeholder="公司名称" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model.trim="state.dataForm.companyAddr" placeholder="公司地址" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="state.getDataList()">搜索</el-button>
      </el-form-item>

      <el-form-item>
        <el-button v-if="state.hasPermission('api:tmcompany:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
      </el-form-item>
      <el-form-item>
        <el-button v-if="state.hasPermission('api:tmcompany:delete')" type="danger" @click="state.deleteHandle()">删除</el-button>
      </el-form-item>
    </el-form>
    <!-- <div class="cxzcxztrxtr">
      <dxmap></dxmap>
    </div> -->
    <el-table v-loading="state.dataListLoading" :data="state.dataList" border @selection-change="state.dataListSelectionChangeHandle" style="width: 100%">
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <!-- <el-table-column prop="id" label="主键ID" header-align="center" align="center"></el-table-column> -->
      <!-- <el-table-column prop="companyCode" label="公司编码" header-align="center" align="center"></el-table-column> -->
      <el-table-column prop="companyName" label="公司名称" header-align="center" align="center"></el-table-column>
      <!-- <el-table-column prop="companyShortName" label="公司简称" header-align="center" align="center"></el-table-column> -->
      <!-- <el-table-column prop="companyEnName" label="公司英文名称" header-align="center" align="center"></el-table-column> -->
      <el-table-column prop="companyImg" label="公司logo" header-align="center" align="center" width="100">
        <template #default="scope">
          <el-image style="width: 40px; height: 40px" :src="scope.row.companyImg" />
        </template>
      </el-table-column>
      <!-- <el-table-column prop="contentImg" label="公司封面" header-align="center" align="center"></el-table-column> -->
      <!-- <el-table-column prop="content" label="公司简介" header-align="center" align="center"></el-table-column> -->
      <!-- <el-table-column prop="province" label="省" header-align="center" align="center"></el-table-column>
              <el-table-column prop="city" label="市" header-align="center" align="center"></el-table-column>
              <el-table-column prop="county" label="县" header-align="center" align="center"></el-table-column> -->
      <el-table-column prop="companyAddr" label="公司地址" header-align="center" align="center"></el-table-column>
      <!-- <el-table-column prop="linkMan" label="联系人" header-align="center" align="center"></el-table-column>
      <el-table-column prop="linkManTel" label="联系人电话" header-align="center" align="center"></el-table-column> -->
      <!-- <el-table-column prop="linkManEmail" label="联系人邮箱" header-align="center" align="center"></el-table-column>
              <el-table-column prop="linkManPosition" label="联系人职务" header-align="center" align="center"></el-table-column>
              <el-table-column prop="linkManTwo" label="备用联系人" header-align="center" align="center"></el-table-column>
              <el-table-column prop="linkManTwoTel" label="备用联系人电话" header-align="center" align="center"></el-table-column>
              <el-table-column prop="linkManTwoEmail" label="备用联系人邮箱" header-align="center" align="center"></el-table-column>
              <el-table-column prop="linkManTwoPosition" label="备用联系人职务" header-align="center" align="center"></el-table-column>
              <el-table-column prop="initPwd" label="初始用户密码" header-align="center" align="center"></el-table-column>
              <el-table-column prop="remark" label="备注" header-align="center" align="center"></el-table-column>
              <el-table-column prop="createOwner" label="创建人" header-align="center" align="center"></el-table-column> -->
      <!-- <el-table-column prop="createTime" label="创建时间" header-align="center" align="center"></el-table-column> -->
      <!-- <el-table-column prop="updateOwner" label="修改人" header-align="center" align="center"></el-table-column>
              <el-table-column prop="updateTime" label="修改时间" header-align="center" align="center"></el-table-column> -->
      <el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
        <template v-slot="scope">
          <el-button v-if="state.hasPermission('api:tmcompany:update')" type="primary" link @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
          <!-- <el-button v-if="state.hasPermission('api:tmcompany:delete')" type="primary" link @click="state.deleteHandle(scope.row.id)">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination :current-page="state.page" :page-sizes="[10, 20, 50, 100]" :page-size="state.limit" :total="state.total" layout="total, sizes, prev, pager, next, jumper" @size-change="state.pageSizeChangeHandle" @current-change="state.pageCurrentChangeHandle"> </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update ref="addOrUpdateRef" @refreshDataList="state.getDataList"></add-or-update>
  </div>
</template>

<script lang="ts" setup>
import useView from "@/hooks/useView";
import { reactive, ref, toRefs } from "vue";
import AddOrUpdate from "./tmcompany-add-or-update.vue";

const view = reactive({
  deleteIsBatch: true,
  getDataListURL: "/sys/tmcompany/page",
  getDataListIsPage: true,
  exportURL: "/api/tmcompany/export",
  deleteURL: "/api/tmcompany"
});

const state = reactive({ ...useView(view), ...toRefs(view) });

const addOrUpdateRef = ref();
const addOrUpdateHandle = (id?: number) => {
  addOrUpdateRef.value.init(id);
};
</script>
